package com.smartEdu.commons.portion.hw;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.springframework.stereotype.Component;
import com.smartEdu.commons.Session;

@Component
public class HworkContext {
	private final String GetHworkFromDB = "GetHworkFromDB";
	private final String classPath = "com.smartEdu.commons.portion.hw.";
	public void GetHwork(Session sess, String className) {
		try {
			Class<?> cls= Class.forName(classPath + className);
			Method method = cls.getMethod(GetHworkFromDB);
			String status = (String)method.invoke(cls.newInstance());
			sess.put("status", status);
		} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException e) {
			e.printStackTrace();
		}
	}
}
